An Introduction To Finite State Machines And The State Pattern For Game Development